﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Ext.Net;

namespace DemoExtNet.PhanQuyen.UserControls
{
    public partial class QUNhomQuyenByToChuc_Edit : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void ShowAddNewDialog()
        {
            wdNhomQuyenByToChuc_Edit.Icon = Icon.Add;
            wdNhomQuyenByToChuc_Edit.Title = "Add New";
            this.__NhomQuyenByToChucId.Text = "0";
            this.txtTenNhomQuyenByToChuc.Text = string.Empty;
            this.txtGhiChu.Text = string.Empty;
            this.txtTenNhomQuyenByToChuc.Focus();
            wdNhomQuyenByToChuc_Edit.Show();
            this.txtTenNhomQuyenByToChuc.Focus(false, 20);
        }
        [DirectMethod]
        public void ShowEditDialog(int pNhomQuyenByToChucID,string pTenNhomQuyenByToChuc,string pGhiChu)
        {
            //set up window
            wdNhomQuyenByToChuc_Edit.Icon = Icon.ApplicationEdit;
            wdNhomQuyenByToChuc_Edit.Title = "Edit";
            //Save Id
            this.__NhomQuyenByToChucId.Text = pNhomQuyenByToChucID.ToString();
            //Bind data into the form
            this.txtTenNhomQuyenByToChuc.Text = pTenNhomQuyenByToChuc;
            this.txtGhiChu.Text = pGhiChu;
            //Show window
            wdNhomQuyenByToChuc_Edit.Show();
            this.txtTenNhomQuyenByToChuc.Focus(false, 20);
            
        }
        [DirectMethod]
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            var oQUNhomQuyenByToChuc = new BusinessObject.BusinessEntities.QUNhomQuyenByToChuc();
            oQUNhomQuyenByToChuc.NhomQuyenByToChucID = int.Parse(this.__NhomQuyenByToChucId.Text);
            oQUNhomQuyenByToChuc.TenNhomQuyenByToChuc = this.txtTenNhomQuyenByToChuc.Text.Trim();
            oQUNhomQuyenByToChuc.GhiChu = this.txtGhiChu.Text.Trim();
            oQUNhomQuyenByToChuc.Save();
            ((PhanQuyen)this.Page).BindData_NhomQuyenByToChuc();
            //Hide window
            wdNhomQuyenByToChuc_Edit.Hide();
        }
    }
}